import requests
from pyquery import PyQuery as dp
import os

n=int(input('请输入你需要爬取的页数：'))
for i in range(1,n+1):
    headers = {

        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
    }
    url='http://www.bbsnet.com/doutu/page/{}'.format(i)

    r=requests.get(url,headers=headers,timeout=5).text
    doc=dp(r)
    zoom = doc('.zoom img ').items()

    for j in zoom:
        img_url = j.attr('src')
        img_title=j.attr('alt')
        images = requests.get(img_url, headers=headers, timeout=5).content
        print(img_title,img_url)

